import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LIUYANJIAO
 * Date: 2024-05-07
 * Time: 10:22
 *///TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
    public static int[] eliminateDupNums(int[]arr){
       int[]arr2=new int[100];
        Arrays.fill(arr2, -1);

        int n=0;
        for (int i = 0; i < 100; i++) {
            for (int j = 0; j <= n; j++) {
                if(arr[i]==arr2[j]){
                    break;
                }if(j==n){
                    arr2[n++]=arr[i];
                    break;
                }
            }
        }return arr2;


    }
    public static int[] createIntList(int[]arr){
        Random random=new Random();
        for (int i = 0; i < 100; i++) {
            arr[i]= random.nextInt(101);
        }
        return arr;
    }
    public static void main(String[] args) {
        int[]arr=new int[100];
        createIntList(arr);
        System.out.println("创建的数组如下：");
        for(int i=0;i<100;i++){
            if(i!=0&&i%10==0){
                System.out.print("\n");
            }
            System.out.printf("%5d",arr[i]);
        }
        System.out.println("\n"+"去除重复元素后，数组如下：");
        int[]arr2=eliminateDupNums(arr);

        for (int i = 0; i < 100; i++) {
            if(i!=0&&i%10==0){
                System.out.print("\n");
            }
            if(arr2[i]!=-1){
                System.out.printf("%5d",arr2[i]);
            }
        }



    }
    public static void main4(String[] args) {
        Scanner scanner=new Scanner(System.in);

        int[]arr1=new int[10];
        System.out.println("请输入10个0-9之间的数字：");
        for (int i = 0; i < 10; i++) {
            arr1[i]=scanner.nextInt();
        }
        int[]arr2=new int[10];

        int n=0;
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                if(arr1[i]==arr2[j]){
                    break;
                }if(j==9){
                    arr2[n++]=arr1[i];
                }

            }

        }
        for (int i = 0; i < n; i++) {
            System.out.print(arr2[i]+" ");
        }
    }
    public static void countint(int[] arr){
        int[] counter=new int[9];
        for (int i = 0; i < 100; i++) {
           counter[arr[i]-1]++;
        }
        for (int i = 1; i < 10; i++) {

            System.out.println(i+"的出现次数："+counter[i-1]);
        }
    }
    public static void countchar(char[]arr){
        int[]count=new int[26];
        for (int i = 0; i < 100; i++) {
            count[(int)(arr[i]-'a')]++;
        }
        for (int i = 0; i < 26; i++) {
            System.out.print((char)('a'+i)+":"+count[i]+"  ");
        }
    }

    public static void main2(String[] args) {
        char[]arr=new char[100];
        Random random=new Random();
        for (int i = 0; i < 100; i++) {
            arr[i]=(char) (random.nextInt(26)+'a');
        }
        countchar(arr);

    }
    public static void main1(String[] args) {
        int[]arr=new int[100];
        Random random=new Random();
        for (int i = 0; i < 100; i++) {
            arr[i]= random.nextInt(9)+1;
        }
        for (int i = 0; i < 100; i++) {
            if(i%10==0&&i!=0){
                System.out.print("\n");
            }
            System.out.print(arr[i]+"\t");

        }
        System.out.print("\n");
        countint(arr);

    }
}